package StudyCode.summary.mycollection;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class GetFirstNameAndLastNameArrayFromFullName {
	public static String[] getFirstNameAndLastNameArrayFromFullName(String fullName) {
		String[] firstnameAndLastnameArr = fullName.split(" ");
		if (firstnameAndLastnameArr.length == 2) {
			return firstnameAndLastnameArr;
		} else if (firstnameAndLastnameArr.length == 1) {
			String firstName = firstnameAndLastnameArr[0];
			firstnameAndLastnameArr = new String[2];
			firstnameAndLastnameArr[0] = firstName;
			firstnameAndLastnameArr[1] = "";
			return firstnameAndLastnameArr;
		} else if (firstnameAndLastnameArr.length > 2) {
			String firstName = firstnameAndLastnameArr[0];
			String lastName = firstnameAndLastnameArr[2];

			firstnameAndLastnameArr = new String[2];
			firstnameAndLastnameArr[0] = firstName;
			firstnameAndLastnameArr[1] = lastName;
			return firstnameAndLastnameArr;
		} else {
			firstnameAndLastnameArr = new String[2];
			firstnameAndLastnameArr[0] = "";
			firstnameAndLastnameArr[1] = "";
			return firstnameAndLastnameArr;
		}
	}
}
